﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Kaidou.Model;
using Kaidou.Persister;
using Kaidou.Util;
using Kaidou.Bll;
using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;

public partial class seal_seal_report_conf : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        LoginModel loginModel = (LoginModel)Session["loginModel"];

        if (loginModel == null)
        {
            Response.Redirect("../login.aspx");
        }

        if (!loginModel.isKumiaiin())
        {
            Response.Redirect("../menu.jsp");
        }

        if (loginModel.isKumiaiin() && sessioncontrol.control())
        {
            Response.Redirect("../control.aspx");
        }
    }

    protected void login_confirm(object sender, EventArgs e)
    {
        try
        {
            sb.Enabled = false;
            Report rpt = (Report)Session["report"];
            TRN_ReportManager manager = new TRN_ReportManager();
            manager.insertReport(rpt, (LoginModel)Session["loginModel"], Resources.Resource.ResourceManager, GetRootPath());
            Response.Redirect("seal_report_comp.aspx",false);
        }
        catch (Exception e1)
        {
            LogManager.error("seal_seal_report_conf login_confirm "+e1.Message);
            throw new Exception("insertReport - fail" + e1.Message + e1.StackTrace);
        }
    }

    public static string GetRootPath()
    {
        string AppPath = "";
        HttpContext HttpCurrent = HttpContext.Current;
        if (HttpCurrent != null)
        {
            AppPath = HttpCurrent.Server.MapPath("~");
        }
        else
        {
            AppPath = AppDomain.CurrentDomain.BaseDirectory;
            if (Regex.Match(AppPath, @"\\$", RegexOptions.Compiled).Success)
                AppPath = AppPath.Substring(0, AppPath.Length - 1);
        }
        return AppPath;
    }
}
